package com.leyou.item.controller;


import com.leyou.item.dto.CategoryDTO;
import com.leyou.item.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.websocket.server.PathParam;
import java.util.List;
@RestController
public class CategoryController {
    @Autowired
    private CategoryService categoryService;

    /**
     * 根据父id查询种类
     * @param pid
     * @return
     */
    @GetMapping("/category/of/parent")
    public ResponseEntity <List<CategoryDTO>>findCategoryByPid(
    @RequestParam("pid") Long pid){
        List<CategoryDTO> categoryDTOList = categoryService.findCategoryByPid(pid);
        return ResponseEntity.status(HttpStatus.OK).body(categoryDTOList);
    }
    //根据分类id的集合查询分类对象的集合

    @RequestMapping("/category/list")
    public ResponseEntity<List<CategoryDTO>>findByCategorysByIds(@RequestParam List<Long> ids){
        List<CategoryDTO> list=categoryService.findByCategorysByIds(ids);
        return ResponseEntity.ok(list);


    }





}
